﻿using System.IO;
using System.Xml.Serialization;

namespace OfficeClip.OpenSource.Logger
{
    class Program
    {
        static void Main(string[] args)
        {
            Log log = new Log(GetLogConfig())
                      {
                          DefaultCategory = "Category-1",
                          DefaultUser = "email1@email.com"
                      };
            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");
            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");
            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");

            log.DefaultCategory = "Category-2";
            log.DefaultUser = "email2@email.com";

            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");
            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");
            log.WriteError("Error Title", "Error Description");
            log.WriteWarning("Warning Title", "Warning Description");
            log.WriteDebug("Debug Title", "Debug Description");
            log.WriteFatalError("Fatal Title", "Fatal Description");
            log.WriteInfo("Info Title", "Info Description");

        }

        private static LogConfig GetLogConfig()
        {
            string path = LogConstants.GetSetupDir() + @"\logger.xml";
            return LogConstants.DeserializeLogConfig(path);
            //LogConfig logConfig = null;
            //string path = LogConstants.GetSetupDir() + @"\logger.xml";
            //XmlSerializer serializer = new XmlSerializer(typeof(LogConfig));
            //FileStream fs = new FileStream(path, FileMode.Open);
            //logConfig = (LogConfig)serializer.Deserialize(fs);

            //return logConfig;
        }
    }
}
